package org.example.taskmaster.sorters;

public abstract class Sorter {
	// types of sorters
	public static final String ALPHABETIC = "Alphabetic";
	public static final String COMPLETE = "Complete";
	public static final String DUE_DATE = "Due Date";
	// member data
	protected int sortDescending;
	protected String type;
	// Constructor
	public Sorter() {
		type = "abstract";
		sortDescending = 0;
	}
	
	// Factory
	public static Sorter getSorter(String type) {
		if (type.equals(ALPHABETIC)) {
			return new AlphabeticalSorter();
		} else if (type.equals(COMPLETE)) {
			return new CompletedSorter();
		} else if (type.equals(DUE_DATE)) {
			return new DueDateSorter();
		} else {
			// default
			return new AlphabeticalSorter();
		}
	} 

	// public methods
	public abstract String orderBy();
	
	public String getType() {return type;}
	
	public void toggleDescending() {
		sortDescending = (-1) * (sortDescending -1);
	}
}
